<template>
	<!-- 会员 => 立即支付 -->
	<view class="bg-white " style="height: 100vh;">
		<view class="numbar">
			<text class="rmb">￥</text>
			<text>{{money}}</text>
			<view class="text">请选择支付方式</view>
		</view>
		<view class="paly">
			<view v-for="(item,index) in mode" :key="index" class="flex-cb item">
				<view class="icon flex align-center">
					<image :src="item.img" mode=""></image>
					<text>{{item.text}}</text>
				</view>
				<text class="cuIcon-roundcheckfill" ></text>
				<!-- <text class="cuIcon-round" v-else @click="handlemode(index)"></text> -->
			</view>
		</view>
		<view class="button flex-c" @click="pay">立即支付</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				money:'',
				id:'',
				payId:'',
				ischeck:0,
				mode:[
					{
						text:'微信支付',
						img:'/static/wx.png'
					},
					// {
					// 	text:'银行卡支付',
					// 	img:'/static/yhk.png'
					// }
				]
			};
		},
		onLoad(e) {
			console.log(e);
			this.money = e.price
			this.id = e.id
		},
		methods:{
			pay(i){
				this.$api.vip_fees_cj({
					vip_fee_id:this.id,
				},1).then(res=>{
					if(res.code == 200001){
						console.log(res);
						this.payId = res.data.id
						 this.$api.vip_fees_pay({},this.payId,1).then(res=>{
							 console.log(res,'2');
							 
									 uni.requestPayment({
										provider: 'wxpay',
										timeStamp: res.data.timeStamp,
										nonceStr: res.data.nonceStr,
										package: res.data.package,
										signType: res.data.signType,
										paySign: res.data.paySign,
										orderInfo:res.data.prepay_id,
										 success:(r)=>{  
											 console.log(r,3);
											 this.$api.vip_fees_hd({},this.payId,1).then(res=>{
											 	console.log(res,'4');
											 	 if(res.code == 200001){
											 		 uni.navigateBack({
											 		 	delta:1,
														animationDuration:500
											 		 })
											 	 }
											 })
										 }, 
										 fail(err) {
										 	console.log(err);
										 }
									})
									
						 })
					}
				})
			}
		}
	}
</script>

<style lang="scss">
.numbar{
	text-align: center;
	padding: 80rpx 30rpx 0 30rpx;
	text{
		font-size: 72rpx;
		color: #333;
	}
	.rmb{
		font-size: 40rpx;
	}
	.text{
		width: 690rpx;
		border-bottom: #ebebeb solid 1rpx;
		padding: 20rpx 1rpx;
		margin-top: 86rpx;
		text-align: left;
		font-size: 30rpx;
		color: #333;
		font-weight: bold;
	}
}
.paly{
	padding: 0 62rpx;
	.item{
		margin: 63rpx 0;
	}
	.icon{
		image{
			width: 50rpx;height: 50rpx;
			margin-right: 18rpx;
		}
	}
	.cuIcon-roundcheckfill,.cuIcon-round{
		font-size: 40rpx;
	}
	.cuIcon-roundcheckfill{
		color: #1CD699;
	}
}
.button{
	width: 630rpx;
	height: 88rpx;
	background: #1CD699;
	box-shadow: 0px 2px 10px 1px rgba(42,64,92,0.14);
	border-radius: 44rpx;
	position: absolute;
	left: 60rpx;
	bottom: 120rpx;
	font-size: 34rpx;
	color: #fff;
}
</style>
